﻿namespace TestTool.GUI.Controllers
{
    using System;
    using System.Collections.Generic;
    using System.Net.NetworkInformation;
    using System.Net.Sockets;
    using TestTool.Tests.Definitions.Data;

    internal class DiscoveryHelper
    {
        public static List<NetworkInterfaceDescription> GetNetworkInterfaces()
        {
            List<NetworkInterfaceDescription> list = new List<NetworkInterfaceDescription>();
            NetworkInterface[] allNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
            bool flag = false;
            bool flag2 = false;
            foreach (NetworkInterface interface2 in allNetworkInterfaces)
            {
                if ((interface2.NetworkInterfaceType == NetworkInterfaceType.Ethernet) || (interface2.NetworkInterfaceType == NetworkInterfaceType.Wireless80211))
                {
                    foreach (UnicastIPAddressInformation information in interface2.GetIPProperties().UnicastAddresses)
                    {
                        if (information.Address != null)
                        {
                            flag |= information.Address.AddressFamily == AddressFamily.InterNetworkV6;
                            flag2 |= information.Address.AddressFamily == AddressFamily.InterNetwork;
                        }
                        list.Add(new NetworkInterfaceDescription(interface2, information.Address));
                    }
                }
            }
            return list;
        }
    }
}

